normalize request URI and resolve hostname using x-cdn-real-host header#149
Open
ruslanti wants to merge 2 commits into
Open
normalize request URI and resolve hostname using x-cdn-real-host header#149ruslanti wants to merge 2 commits into
ruslanti wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the HTTP executors to (1) use the x-cdn-real-host header for determining the effective host and (2) normalize origin-form (relative) request URIs into absolute URIs so guest code consistently observes scheme + authority.
Changes:
- Switch wasi-http hostname resolution from
SERVER_NAME_HEADERtoX_CDN_REAL_HOST. - Add origin-form URI normalization in the non-wasi HTTP executor, intended to mirror wasi-http behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/http-service/src/executor/wasi_http.rs | Uses x-cdn-real-host for hostname resolution in URI normalization, replacing the prior SERVER_NAME_HEADER usage. |
| crates/http-service/src/executor/http.rs | Adds hostname resolution and origin-form → absolute URI normalization for the non-wasi executor to align guest-visible URI shape with wasi-http. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
df6dd7f to
eb3d47f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
crates/http-service/src/executor/wasi_http.rs:85
- Even with the fallback logic above,
hostname.parse().ok()can still leaveuparts.authorityasNone; withuparts.schemeset this makesUri::from_partsreturn an error. Consider making authority assignment infallible (e.g., last-resort fallback to a static authority) so a bad/unsupported hostname cannot take down request execution.
if parts.uri.scheme().is_none() {
let mut uparts = parts.uri.clone().into_parts();
uparts.scheme = Some(::http::uri::Scheme::HTTP);
if uparts.authority.is_none() {
uparts.authority = hostname.parse().ok()
}
parts.uri = Uri::from_parts(uparts)?;
}
…y and maintainability
46992c3 to
320ca05
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.